<template>
    <div class="container">
      <div class="banner">
        <img src="../../../static/images/newsBanner.jpg" class="img-res">
      </div>
      <article class="companyList">
        <h2>COMPANY NEWS</h2>
        <el-row class="list">
          <el-col :span="24" v-for="(item,index) in companyList" :key="index">
            <div class="grid-content">
              <router-link :to="'/News/' + (item.id)">
                <h3>{{ item.title }}</h3>
                <i class="data">{{ dataTime(item.senddate) }}</i>
                <p>
                  {{ item.description }}
                </p>
              </router-link>
            </div>
          </el-col>
        </el-row>
        <div class="page">
          <el-pagination
          background
          layout="prev, pager, next"
          :pager-count=pager
          @current-change="handleCurrentChange"
          :total="total">
          </el-pagination>
        </div>
      </article>
    </div>
</template>
<script>
import axios from 'axios'
export default {
  data () {
    return {
      companyList: {},
      total: null,
      pager: 5
    }
  },
  mounted () {
    axios.get('/news/list/industry').then(response => {
      this.companyList = response.data.data.data
      this.total = response.data.data.count
    }).catch(function (error) {
      console.log(error)
    })
  },
  methods: {
    handleCurrentChange (val) {
      axios.get('/news/list/industry?page=' + val).then(response => {
        this.crusherList = response.data.data.data
      }).catch(function (error) {
        console.log(error)
      })
    },
    dataTime (time) {
      const timestamp = time
      const newDate = new Date()
      newDate.setTime(timestamp * 1000)
      time = newDate.toLocaleDateString()
      return time
    }
  }
}
</script>
<style lang="sass" scoped>
.container
  padding: 52px 0 66px 0
.companyList
  padding: 1rem
  h2
    border-left: 0.2rem solid #db3f28
    font-size: 1.4rem
    padding: 0.8rem 1rem
  .list
    .el-col-24
      border-bottom: 1px solid #ccc
      margin-borttom: 1rem
      a
        color: #444
        h3
          font-size: 1.6rem
        p
          font-size: 1.2rem
        i
          font-weight: 600
.page
  text-align: left
  margin: 1rem 0
</style>
